/*
* Copyright (c) 2011 . All Rights Reserved.
*/
package com.cgmnx.admin.common.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: dongdong.yang  Date: 14-9-18 Time: 下午1:24
 * @version: \$Id$
 */
public class IpUtil {

    private static final String IP_REGEX = "((?:(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(?:25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d))))";
    private static final Pattern PATTERN = Pattern.compile(IP_REGEX);

    public static boolean isRealIp(String ip) {

        if (StringUtils.isBlank(ip)) {
            return Boolean.FALSE;
        }

        Matcher matcher = PATTERN.matcher(ip);
        return matcher.matches();
    }
}
